import { defineStore } from "pinia";
import { unref } from "vue";
const useTableConfigStore = defineStore("tableConfig", {
    state: () => ({
        tableConfig: <any>{},
    }),
    actions: {
        // 获取配置
        getTableConfig(_key: string) {
            if (JSON.stringify(unref(this.tableConfig)) != "{}") {
                return this.tableConfig[_key];
            } else {
                return null;
            }
        },
        // 设置配置
        setTableConfig(key: any, value: any) {
            if (value !== null && value !== "") {
                this.tableConfig[key] = value;
            }
        },
        // 清空配置
        cleanTableConfig() {
            this.tableConfig = {};
        },
        // 初始配置
        initTableConfig(data: Object) {
            this.tableConfig = data;
        },
    },
});

export default useTableConfigStore;
